package com.special.threademo.model;


import com.special.threademo.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * @author LiuYC
 * @version 1.0.0
 * @create 2020-12-21 11:04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultMessage<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> ResultMessage<T> success(T data) {
        return new ResultMessage<>(Constants.StatusCode.SUCCESS, "操作成功", data);
    }

    public static ResultMessage success() {
        return new ResultMessage(Constants.StatusCode.SUCCESS, "操作成功", "操作成功");
    }

    public static ResultMessage fail(String code, String msg) {
        return new ResultMessage(code, msg, null);
    }


    public static ResultMessage fail(String msg) {
        return new ResultMessage(Constants.StatusCode.SYSTEM_EXCEPTION, msg, null);
    }
}

